<?php
namespace Client\Table;

use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;

use Zend\Paginator\Paginator;
use Zend\Db\Sql\Where;
use Zend\Db\ResultSet\ResultSet;

class OrderitemTable extends CommonTable
{
    protected $table = 'hy_orderitem';
    protected $id = 'oi_id';

    public function getList($query = array())
    {
        $select = new Select(array('o'=>$this->getTable()));
        $select->columns( array(
            "*"
        ));
    
        $select->where(array('order_id'=>$query['order_id']));
        $select->order(array('o.order_id desc'));
    
        $rowset = $this->selectWith($select);
        $list = $rowset->toArray();
    
        return $list;
    }
    
    public function getFoodList($query = array())
    {
        $select = new Select(array('o'=>$this->getTable()));
        $select->columns( array(
            "*"
        ));
        $select->where(array('order_id'=>$query['order_id']));
        $select->order(array('o.oi_meal_send_time asc'));
    
        $rowset = $this->selectWith($select);
        $list = $rowset->toArray();
        return $list;
    }
    
    public function getFirstItem($order_id)
    {
        $rowset = $this->select(array('order_id' => $order_id));
        $row = $rowset->current();
        return $row;
    }
}